<?php
namespace app\index\controller;

use think\Controller;
use think\View;

class Common extends controller
{   
	
    public function getQRcode(){
    	header('Content-Type: text/plain; charset=utf-8');

      $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxa641018b058e4ac9&secret=29a4e9463afe4b90a1e2ca2ed2bff310";
       
      $access_token = json_decode(file_get_contents($url),true);//获取用户openid与session_key
      
    	$access_token = $access_token['access_token'];
    

	    $url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=$access_token";
	   
        
       for ($i = 1 ; $i < 10 ; $i++) { 
       	   $query = '0419438614293584'.$i;
           $data['path']  = "/pages/index/index?query=$query";
           $data['width'] = "10";

           $result = httpRequest($url,'POST',json_encode($data));
           file_put_contents("test/$i.png", $result);
       }
	    
	}

}